﻿Imports System.Data.OleDb
Imports System.Xml
Imports System.Text
Public Class RFeedICCTeams
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Clear()
        Response.ContentType = "application/rss+xml"
        Dim objX As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
        objX.WriteStartDocument()
        objX.WriteStartElement("rss")
        objX.WriteAttributeString("version", "2.0")
        objX.WriteStartElement("channel")

        Dim cmd As New OleDbCommand("SELECT ID, Nation, GoverningBodyName, GoverningBodyName, CurrentTestRankings, CurrentT20Rankings, TeamLogo, NationFlag FROM InternationalCricketTeams  order by InternationalCricketTeams.ID", New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnStringWorldsCricket").ConnectionString))
        cmd.Connection.Open()
        Dim dr As OleDbDataReader = cmd.ExecuteReader()

        objX.WriteElementString("title", "ICC Teams Names")
        objX.WriteElementString("link", "http://localhost:56630/ICCTeams.aspx")
        objX.WriteElementString("description", "Cricket Forum  is the simplest ASP.NET website which gives information on Cricket Game!")
        objX.WriteElementString("language", "en-us")
        objX.WriteElementString("ttl", "60")
        objX.WriteElementString("lastBuildDate", String.Format("{0:R}", DateTime.Now))

        Do While dr.Read()
            objX.WriteStartElement("item")
            objX.WriteElementString("title", dr("Nation").ToString())
            objX.WriteElementString("description", dr("GoverningBodyName").ToString())
            objX.WriteStartElement("guid")
            objX.WriteAttributeString("isPermaLink", "true")
            objX.WriteString("http://localhost:56630/GoverningBody.aspx?ID=" & dr("ID").ToString())
            objX.WriteEndElement()
            objX.WriteEndElement()
        Loop

        objX.WriteEndElement()
        objX.WriteEndElement()
        objX.WriteEndDocument()
        objX.Flush()
        objX.Close()
        Response.End()
    End Sub

End Class